import request from '@/utils/request'

// 查询角色模块列表
export function listRoles(query) {
  return request({
    url: '/system/roles/list',
    method: 'get',
    params: query
  })
}

// 查询角色模块详细
export function getRoles(id) {
  return request({
    url: '/system/roles/' + id,
    method: 'get'
  })
}

// 新增角色模块
export function addRoles(data) {
  return request({
    url: '/system/roles',
    method: 'post',
    data: data
  })
}

// 修改角色模块
export function updateRoles(data) {
  return request({
    url: '/system/roles',
    method: 'put',
    data: data
  })
}

// 删除角色模块
export function delRoles(id) {
  return request({
    url: '/system/roles/' + id,
    method: 'delete'
  })
}




// ✅ 新增接口：查询已关联用户列表
export function listAssociatedUsers(query) {
  return request({
    url: '/system/role-associated-users',
    method: 'get',
    params: query
  });
}

// ✅ 新增接口：取消用户关联
export function cancelUserAssociation(userIds) {
  return request({
    url: '/system/role-associated-users/cancel-association',
    method: 'post',
    data: userIds
  });
}
